package cn.yx.user.controller.admin;

import cn.yx.common.core.pojo.IdCond;
import cn.yx.common.core.pojo.PageVo;
import cn.yx.common.core.pojo.ResponseVo;
import cn.yx.common.log.annotation.SysLog;
import cn.yx.common.web.controller.AbstractAdminController;
import cn.yx.user.cond.UserAccountCond;
import cn.yx.user.dto.UserAccountDto;
import cn.yx.user.mapping.UserAccountMapping;
import cn.yx.user.service.UserAccountService;
import cn.yx.user.vo.in.UserAccountInVo;
import cn.yx.user.vo.out.UserAccountOutVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>用户账户后台管理控制器</p>
 *
 * @author Wgssmart
 */
@RestController
@RequestMapping("/admin/user-account")
@RefreshScope
@Api(tags = "用户账户管理")
public class UserAccountAdminController extends
        AbstractAdminController<UserAccountInVo, UserAccountOutVo, UserAccountDto, UserAccountCond, Long> {

    private final UserAccountService userAccountService;

    public UserAccountAdminController(UserAccountService userAccountService) {
        super(userAccountService, UserAccountMapping.INSTANCE);
        this.userAccountService = userAccountService;
    }

    @Override
    @PostMapping("save")
    @SysLog(description = "保存用户账户", excludeProperties = {"password"})
    @ApiOperation(value = "保存用户账户")
    public ResponseVo<Void> save(@RequestBody @Validated UserAccountInVo userAccountInVo) {
        return super.save(userAccountInVo);
    }

    @Override
    @PostMapping("get-by-id")
    @SysLog(description = "根据id获取用户账户")
    @ApiOperation(value = "根据id获取用户账户")
    public ResponseVo<UserAccountOutVo> getOne(@RequestBody @Validated IdCond<Long> idCond) {
        return super.getOne(idCond);
    }

    @Override
    @PostMapping("list-all")
    @SysLog(description = "查询所有用户账户")
    @ApiOperation(value = "查询所有用户账户")
    public ResponseVo<PageVo<UserAccountOutVo>> listAll() {
        return super.listAll();
    }
}
